{{#unless paSystemActive}}
<section class="pasystem-section">
  <div class="alert alert-danger">{{{t this "pasystem-disabled"}}}</div>
</section>
{{/unless}}

<section class="pasystem-section">
  <header class="pasystem-section-header">
    <h3>{{{t this "Banners"}}}</h3>
        <a href="{{{newURL this 'banners' 'new'}}}" ><button type="button" class="btn btn-primary btn-sm pull-right">{{{t this "Create Banner"}}}</button></a>
  </header>

  <table class="pasystem-table table table-striped table-hover table-condensed">
    <thead>
      <tr>
        <th>{{{t this "Message"}}}</th>
        <th>{{{t this "Type"}}}</th>
        <th>{{{t this "Active"}}}</th>
        <th>{{{t this "From"}}}<span class="si si-down" aria-hidden="true"></span></th>
        <th>{{{t this "Until"}}}</th>
        <th><!-- actions --></th>
      </tr>
    </thead>
    <tbody>
      {{#each banners}}
      <tr>
        <td>{{this.message}}</td>
        <td>{{{t this "banner_type" this.type}}}</td>
        <td>{{this.active}}</td>
        <td>{{show-time this this.startTime}}</td>
        <td>{{show-time this this.endTime}}</td>
        <td class="actions">
            <a href="{{{actionURL this 'banners' this.uuid "edit"}}}"><button type="button" class="btn btn-primary btn-xs">{{{t this "Edit"}}}</button></a>
            <a href="{{{actionURL this 'banners' this.uuid "delete"}}}" class="pasystem-delete-btn" data-record-type="banner"><button type="button" class="btn btn-danger btn-xs"><i class="si si-trash"></i></button></a>
        </td>
      </tr>
      {{/each}}
    </tbody>
  </table>
</section>

<section class="pasystem-section">
  <header class="pasystem-section-header">
    <h3>{{{t this "Popups"}}}</h3>
    <a href="{{{newURL this 'popups' 'new'}}}" ><button type="button" class="btn btn-primary btn-sm pull-right">{{{t this "Create Popup"}}}</button></a>
    <a title="{{{t this "Download ToolTip"}}}" href="/pasystem-tool/pasystem-samples.zip" ><button class="btn btn-default btn-sm btn-link pull-right">{{{t this "Download Templates"}}}</button></a>
  </header>

  <table class="pasystem-table table table-striped table-hover table-condensed">
    <thead>
      <tr>
        <th>{{{t this "Description"}}}</th>
        <th>{{{t this "Active"}}}</th>
        <th>{{{t this "From"}}}<span class="si si-down" aria-hidden="true"></span></th>
        <th>{{{t this "Until"}}}</th>
        <th><!-- actions --></th>
      </tr>
    </thead>
    <tbody>
      {{#each popups}}
      <tr>
        <td>{{this.descriptor}}</td>
        <td>{{this.active}}</td>
        <td>{{show-time this this.startTime}}</td>
        <td>{{show-time this this.endTime}}</td>    
        <td class="actions">
            <a href="{{{actionURL this 'popups' this.uuid "preview"}}}" class="preview-btn"><button type="button" class="btn btn-default btn-xs btn-link">{{{t this "Preview"}}}</button></a>
            <a href="{{{actionURL this 'popups' this.uuid "edit"}}}" ><button type="button" class="btn btn-primary btn-xs">{{{t this "Edit"}}}</button></a>
            <a href="{{{actionURL this 'popups' this.uuid "delete"}}}" data-record-type="popup" class="pasystem-delete-btn"><button type="button" class="btn btn-danger btn-xs"><i class="si si-trash"></i></button></a>
        </td>
      </tr>
      {{/each}}
    </tbody>
  </table>
</section>

<section class="pasystem-section">
  <header class="pasystem-section-header">
    <h3>{{{t this "Timezone Check"}}}</h3>
  </header>

  {{#if timezoneCheckActive}}
  <div class="alert alert-success">{{{t this "timezone-check-active"}}}</div>
  {{else}}
  <div class="alert alert-danger">{{{t this "timezone-check-disabled"}}}</div>
  {{/if}}
</section>

<script id="pasystemDeleteConfirmationModalTemplate" type="text/template">
  <div class="modal fade" id="pasystemDeleteConfirmationModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-label="{{{t this "Close"}}}"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title">
            {if recordType == "banner"}
              {{{t this "Delete Banner"}}}
            {else}
              {{{t this "Delete Popup"}}}
            {/if}
          </h4>
        </div>
        <div class="modal-body">
          <p>
            {if recordType == "banner"}
              {{{t this "Are you sure you want to delete this banner?"}}}
            {else}
              {{{t this "Are you sure you want to delete this popup?"}}}
            {/if}
          </p>
        </div>
        <div class="modal-footer">
          <form action="${deleteURL}" method="POST">
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{{t this "Close"}}}</button>
            <button type="submit" class="btn btn-danger">
              {if recordType == "banner"}
                {{{t this "Delete Banner"}}}
              {else}
                {{{t this "Delete Popup"}}}
              {/if}
            </button>
          </form>
        </div>
      </div>
    </div>
  </div>
</script>
